fix(guard): waive same-turn freshness for repos with no remote (v3.8.5)#152
Merged
Merged
Conversation
…5) (#149) A brand-new `git init` repo has no remote, so `git fetch` (No remote repository specified) and `git pull --ff-only` (no tracking information) both fail — yet the same-turn freshness gate demanded one before any review/edit/test/commit, locking the agent out of its own new repo. A repo with zero configured remotes has no upstream to be stale against, so the freshness check is vacuous there. `decide()` now waives it for a no-remote repo (`repo-work-fresh-base` no longer fires); the rules-note consult is unchanged. Detection (`_repo_has_remote`) is subprocess-free — it reads `<repo>/.git/config` for a `[remote "…"]` stanza — and conservative: a `.git` pointer file (linked worktree/submodule), an unreadable config, or any resolution error is treated as has-a-remote, so freshness is only ever waived when zero remotes are positively confirmed. A repo that has a remote is completely unaffected. Patch bump 3.8.4 → 3.8.5; CHANGELOG entry added. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #149.
Problem
Inside a brand-new
git initrepo with no remote,omind guardlocked the agent out of its own repo. The same-turn freshness gate (repo-work-fresh-base) demanded agit fetch/git pullbefore any review/edit/test/commit — but a repo with no remote has nothing to fetch:git fetch→fatal: No remote repository specified.git pull --ff-only→There is no tracking information for the current branch.The two remediations the block message suggests both fail (only
git fetch --all --pruneincidentally exits 0 as a no-op over zero remotes), so it reads as a hard deadlock — exactly the first steps of scaffolding a new project.Fix
A repo with zero configured remotes has no upstream to be stale against, so the freshness check is vacuous there.
decide()now waives the freshness demand for a no-remote repo (repo-work-fresh-baseno longer fires); the rules-note consult (repo-work-read-git-rules) is unchanged.Detection lives in a new
_repo_has_remote(repo):<repo>/.git/configfor a[remote "…"]stanza, matching the module's no-subprocess-on-the-hot-path design.True(keep the freshness demand) on any doubt: a.gitpointer file (linked worktree / submodule, whose remotes live in the shared config), an unreadable config, or a resolution error. Freshness is waived only when we positively read the repo's own config and find zero remotes.This makes the change a pure correctness fix for new local repos and never a loosening for a repo that has a remote.
Tests
test_repo_has_remote_detects_configured_remotes—Falsefor a freshgit init,Trueaftergit remote add,True(conservative) for a non-repo path.test_new_repo_without_a_remote_does_not_demand_freshness— the rules-note consult is still required, but freshness is then waived (wasrepo-work-fresh-basebefore this change).test_new_repo_with_a_remote_still_demands_freshness— a repo with a remote is unaffected:repo-work-fresh-basestill fires.Full suite green (
ruff check .clean;pytest756 passed, 1 skipped).Version
Patch bump
3.8.4 → 3.8.5(bug fix) acrosspyproject.toml,src/omind/__init__.py,uv.lock, with aCHANGELOG.mdentry.🤖 Generated with Claude Code
Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/